/*
 * @ NeighboringElementsArray.java
 *
 */

import java.util.Scanner;

/**
* The class NeighboringElementsArray 
* finds two elements with the minimum distance.
* Displays the index of the first element.
*
* @version 1.01 
* @date    18.01.2013
* @author  Yaroslav Tabachnyy
* @email   Yaroslav.Tabachnyy@gmail.com
*/

public class NeighboringElementsArray {

public static void main (String[] args) {

	Scanner in = new Scanner(System.in);

		System.out.println("Enter size of array: ");

	int sizeOfArray = in.nextInt();

		int[] arr = new int[sizeOfArray];

	System.out.println("Enter the values of the elements:");

	for (int i=0; i<sizeOfArray; i++) {

			arr[i] = in.nextInt();

	}

	int resIndex = 0;

		for (int i=1; i < (sizeOfArray-1); i++) {

		if ( Math.abs(arr[i] - arr[i+1]) 
		< Math.abs(arr[resIndex] - arr[resIndex+1]) ) {

			resIndex = i;

			}

		} 

System.out.println("Result: " + resIndex);

	}

}